package day7;

import org.junit.Test;

public class BaoZhuang {
	@Test
	public void  test1() {
		String str = 12 + "";
		System.out.println(str);
		str = str + 2;
		System.out.println(str);
		String str2 = Double.toString(3.14);
	}
	
	@Test
	public void test2() {
		String str = "20";
		int value1 = Integer.parseInt(str);
		System.out.println(value1);
		
		Integer integer = new Integer(str);
		int value2 = integer.intValue();
		System.out.println(value2);
		
		String str2 = "3.14";
		double d = Double.parseDouble(str2);
		System.out.println(d);
	}
	
	@Test
	public void test3() {
		// 自动装箱和拆箱
		// Integer integer = new Integer(4);
		Integer integer = 4;// 自动装箱，等价于上面的操作
		int num = 4;
		num = num + 2;
		integer = integer + 2;// integer。intValue() + 2 = 6;
		// 得到int类型的6，赋值给Integer类型，自动拆箱
		System.out.println(integer);
		String str = "1234bull";
		System.out.println(Integer.parseInt(str));//java.lang.NumberFormatException: For input string: "1234bull"


	}
	
	
}
